package cn.iocoder.yudao.module.picturebook.dal.mysql.favorites;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.picturebook.dal.dataobject.favorites.FavoritesDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.picturebook.controller.admin.favorites.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 用户收藏 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface FavoritesMapper extends BaseMapperX<FavoritesDO> {

    default PageResult<FavoritesDO> selectPage(FavoritesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FavoritesDO>()
                .eqIfPresent(FavoritesDO::getUserId, reqVO.getUserId())
                .eqIfPresent(FavoritesDO::getBookId, reqVO.getBookId())
                .eqIfPresent(FavoritesDO::getCollectionType, reqVO.getCollectionType())
                .betweenIfPresent(FavoritesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FavoritesDO::getId));
    }
    default PageResult<FavoritesDO> selectPageByUserId(FavoritesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FavoritesDO>()
                .eqIfPresent(FavoritesDO::getUserId, reqVO.getUserId())
                .eqIfPresent(FavoritesDO::getBookId, reqVO.getBookId())
                .eqIfPresent(FavoritesDO::getCollectionType, reqVO.getCollectionType())
                .betweenIfPresent(FavoritesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FavoritesDO::getId)
        );
    }


    boolean deleteByBookIdAndUserId(@Param("bookId") Long bookId,@Param("userId") Long userId);

    List<Long> selectBookIdsByUserId(Long userId);
}